Skip to content

fix(http): remove Proxy-Authorization on redirect when the proxy changes - #2256

Merged
Vincent Biret (baywet) merged 3 commits into
microsoft:mainfrom
hardikkaurani:fix/redirect-different-proxy-scrub-proxy-auth
Nov 16, 2026
Merged

Vincent Biret (baywet) merged 3 commits into
microsoft:mainfrom
hardikkaurani:fix/redirect-different-proxy-scrub-proxy-auth

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Summary

When following an HTTP redirect, RedirectHandlerOption.DEFAULT_SCRUB_SENSITIVE_HEADERS removes Authorization and Cookie headers upon origin changes, and removes Proxy-Authorization when no proxy is configured or the proxy is bypassed for the new destination URL.

However, if a redirect target is configured with a different proxy than the preceding request, the existing check did not strip Proxy-Authorization, potentially leaking proxy credentials to an unintended proxy. This pull request ensures that Proxy-Authorization is removed when the resolved proxy changes across hops, bringing Kiota Java into parity with the RFC 7235 / RFC 9110 credential isolation semantics established in Kiota .NET (PR #867).

Changes

  • RedirectHandlerOption.DEFAULT_SCRUB_SENSITIVE_HEADERS:
    • Compares the proxy resolved for newUrl with the proxy resolved for originalUrl.
    • Removes Proxy-Authorization if the proxy becomes inactive (newProxy == null) or changes (!Objects.equals(newProxy, originalProxy)).
    • Preserves Proxy-Authorization when the destination routes through the same proxy.
    • Updates Javadoc to reflect the enhanced proxy change scrubbing.
  • RedirectHandlerTests:
    • Adds regression test redirectToUrlWithDifferentProxyStripsProxyAuth reproducing credential stripping when redirecting between distinct proxies.
    • Adds regression test multiHopRedirectBackToOriginalProxyStripsIntermediateProxyAuth validating multi-hop isolation so intermediate proxy credentials are never forwarded to subsequent proxies.

Validation

  • ./gradlew :components:http:okHttp:spotlessCheck: PASSED
  • ./gradlew :components:http:okHttp:test: PASSED (all tests pass)
  • ./gradlew test: PASSED (all repository unit tests pass)

…roxy changes

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
@hardikkaurani
Hardik K (hardikkaurani) requested a review from a team as a code owner November 16, 2026 16:19
Copilot AI balanced review requested due to automatic review settings November 16, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet),

Could you please take a look when you have a chance?

This PR brings Kiota Java into parity with the proxy credential scrubbing behavior recently introduced in Kiota .NET (PR #867):

  • Proxy-Authorization scrubbing on proxy changes: RedirectHandlerOption.DEFAULT_SCRUB_SENSITIVE_HEADERS now compares the resolved proxy for the redirect destination with that of the preceding request. If the proxy changes or becomes inactive, Proxy-Authorization is removed to prevent leaking proxy credentials to another proxy. Redirects staying on the same proxy continue to preserve the header.
  • Regression test coverage: Added unit tests in RedirectHandlerTests covering both single-hop proxy changes and multi-hop redirects back to earlier proxies to ensure credentials are never forwarded across proxy boundaries.

All tests and Spotless formatting checks pass cleanly locally. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new tests do not exercise the full A→B→A redirect loop, leaving a regression that retains proxy credentials on the final request undetected.

1 open issue

Review effort: Balanced

…xy auth scrubbing

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Vincent Biret (@baywet) I have updated the multi-hop redirect test to drive the full A -> B -> A redirect cycle directly through RedirectHandler.intercept(chain).

The test now models an initial hop through Proxy A, receives a 302 to Proxy B where intermediate credentials are supplied on the response request, and subsequently redirects back to Proxy A. Using ArgumentCaptor on chain.proceed, we verify that Proxy-Authorization is scrubbed across both transitions and omitted on the final request forwarded through the chain.

All local tests and Spotless formatting checks pass. Ready for review whenever convenient.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the proxy-credential isolation change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Nov 16, 2026
@baywet
Vincent Biret (baywet) added this pull request to the merge queue Nov 16, 2026
Merged via the queue into microsoft:main with commit 4d35313 Nov 16, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

3 participants